#ifndef ASIOCONTEXTPOOL_H
#define ASIOCONTEXTPOOL_H
#include <boost/asio.hpp>
#include "SingleClass.h"
#include <vector>
using work=boost::asio::io_context::work;
using io_context=boost::asio::io_context;
class asioContextPool:public SingleClass<asioContextPool>{

public:
    io_context& get_io_context();
    void stop_pool();
    ~asioContextPool();
private:
    
    friend class SingleClass<asioContextPool>;
    asioContextPool();  //这里进行初始化
    
    std::vector<std::unique_ptr<io_context>>_io_context_pool;
    //每一个work与一个io_context绑定，避免io_context调用run时无事件导致掉用线程退出
    std::vector<std::unique_ptr<work>> _work_pool;      //这里为什么要存放智能指针呢？
    std::vector<std::thread>_thread_pool;

    //为了实现负载均衡
    int next_io_contex_index;
    int pool_size;
    
};



#endif